<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Movie</title>
	<link type="text/css" rel="stylesheet" href="css/dth.css" />
	<title>Admin Movie</title>
	<style>
.menu7 {
	box-shadow: 6px 11px 10px;
}

.admin_menu_moive {
	background: #0FD1D1 !important;
}

.myTable td:nth-child(6) {
	width: 50px;
	text-align: center;
}
</style>
</h:head>

<h:body>
	<p:ajaxStatus
		style="bottom: 68%;
	    height: 32px;
	    position: fixed;
	    right: 50%;
	    width: 32px;
	    z-index: 99999;">
		<f:facet name="start">
			<p:graphicImage value="images/loading.gif" />
		</f:facet>

		<f:facet name="complete">
			<h:outputText value="" />
		</f:facet>
	</p:ajaxStatus>
	<p:growl id="growl" showDetail="true" sticky="false" />
	<ui:insert name="header">
		<ui:include src="/header/header_dth.xhtml" />
	</ui:insert>
	<div>
		<div class="dth_body_home">
			<ui:insert name="header_banner">
				<ui:include src="/header/header_banner.xhtml" />
			</ui:insert>
			<div class="dth_content">
				<div class="dth_admin_menu">
					<h:form>

						<ui:insert name="header_banner">
							<ui:include src="/header/menu_admin.xhtml" />
						</ui:insert>

					</h:form>
				</div>
				<div class="dth_content_admin">
					<div class="menu_top1">
						<h:form id="dlgform">
							<p:dialog header="insert movie" widgetVar="dlg" id="dlg"
								width="500" height="570" resizable="false">
								<h:panelGroup id="dlgisert">
									<h:inputHidden value="#{movieBean.id}"></h:inputHidden>
									<h:inputHidden value="#{movieBean.fkAdminId}"></h:inputHidden>
									<div class="feild-input">
										<h:outputLabel value="#{msg['book_movie_name']}"
											style="width:60px;"></h:outputLabel>
										<h:inputText value="#{movieBean.name}"></h:inputText>
									</div>
									<div class="feild-input">
										<h:outputLabel value="#{msg['description']}"
											style="width:60px;"></h:outputLabel>
										<p:editor value="#{movieBean.des}" width="400" height="275"
											style="float:left;"></p:editor>
									</div>
									<div class="feild-input">
										<h:outputLabel value="#{msg['book_movie_price']}"
											style="width:60px;"></h:outputLabel>
										<h:inputText value="#{movieBean.price}" style="width:200px;"></h:inputText>
									</div>

									<!-- chon hinh trong form insert -->
									<div class="feild-input">
										<h:outputLabel value="#{msg['image']}" style="width:60px;"></h:outputLabel>
										<h:inputText id="upload" style="width:400px" disabled="true"
											value="#{movieBean.fileName}"></h:inputText>
									</div>
									<div class="feild-input">
										<p:fileUpload fileUploadListener="#{movieBean.upload}"
											mode="advanced" dragDropSupport="true" sizeLimit="1000000"
											allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
											invalidSizeMessage="The maximum file size allowed is 10 Megabytes !"
											invalidFileMessage="You are allowed to upload only images !"
											update=":growl,:dlgform:upload,:dlgform:upload1,:dlgform:imgtemp" />
									</div>

									<div class="feild-action">
										<h:inputHidden value="#{movieBean.fileName}" id="imgtemp"></h:inputHidden>
										<p:commandButton value="#{msg['btn_ok']}"
											oncomplete="dlg.hide()" id="upload1"
											action="#{movieBean.insert}" update=":mainform,:growl">
											<f:param value="#{movieBean.fileName}" name="filename"></f:param>
										</p:commandButton>
										<p:commandButton value="#{msg['btn_cancel']}"
											action="#{movieBean.delImg2()}" oncomplete="dlg.hide()"></p:commandButton>
									</div>
								</h:panelGroup>

							</p:dialog>
						</h:form>

						<h:form id="dlgform2" >
							<p:dialog header="#{msg['btn_edit']} #{msg['menu_admin_movie']}" widgetVar="dlg2"
								id="dlg2" width="600" height="570" resizable="false">
								<h:panelGroup id="dlgupdate">
									<h:inputHidden value="#{movieBean.id}"></h:inputHidden>
									<h:inputHidden value="#{movieBean.fkAdminId}"></h:inputHidden>
									<div class="feild-input">
										<h:outputLabel value="#{msg['book_movie_name']}: *" style="width:60px;"></h:outputLabel>
										<h:inputText value="#{movieBean.name}" required="true"></h:inputText>

									</div>
									<div class="feild-input">
										<h:outputLabel value="#{msg['description']}: *" style="width:60px;"></h:outputLabel>
										<p:editor value="#{movieBean.des}" required="true" width="400"
											height="275" style="float:left;"></p:editor>
									</div>
									<div class="feild-input">
										<h:outputLabel value="#{msg['price']}: *" style="width:60px;"></h:outputLabel>
										<h:inputText value="#{movieBean.price}" required="true"
											style="width:150px;"></h:inputText>
									</div>
									<!-- chon hinh trong form update -->
									<div class="feild-input">
										<h:outputLabel value="#{msg['image']} #{msg['old']}: " style="width:60px;"></h:outputLabel>
										<h:inputText disabled="true" value="#{movieBean.imageOld}"
											style="width:400px;"></h:inputText>
									</div>
									<div class="feild-input">
										<h:outputLabel value="#{msg['image']}: " style="width:60px;"></h:outputLabel>
										<h:inputText id="upload" disabled="true"
											value="#{movieBean.image}" style="width:400px;"></h:inputText>
									</div>
									<div class="feild-input">
										<p:fileUpload fileUploadListener="#{movieBean.upload}"
											mode="advanced" dragDropSupport="true"
											update=":growl,:dlgform2:upload,:dlgform2:upload1,:dlgform2:imgtemp"
											sizeLimit="1000000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
											invalidSizeMessage="The maximum file size allowed is 10 Megabytes !"
											invalidFileMessage="You are allowed to upload only images !"></p:fileUpload>
									</div>
									<div class="feild-action">
										<h:inputHidden value="#{movieBean.imageOld}"></h:inputHidden>
									
										<h:inputHidden value="#{movieBean.image}" id="imgtemp"></h:inputHidden>

										<p:commandButton id="upload1" style="float: right" value="#{msg['btn_ok']}"
											oncomplete="dlg2.hide()" action="#{movieBean.insert}"
											update=":mainform,:growl">
											<f:param value="#{movieBean.image}" name="filename"></f:param>
										</p:commandButton>
										<p:commandButton value="#{msg['btn_cancel']}"
											action="#{movieBean.delImg1()}" oncomplete="dlg2.hide()">
										</p:commandButton>
									</div>
								</h:panelGroup>

							</p:dialog>
						</h:form>


						<h:form id="form_confirm_delete_movie">
							<p:confirmDialog id="confirm_delete_movie"
								message="#{msg['delete_mess']}" header="Xóa phim" width="400"
								showEffect="clip" closable="false" widgetVar="confirm_del_movie">
								<h:panelGroup id="data">
									<h:inputHidden value="#{movieBean.id}"></h:inputHidden>
									<h:inputHidden value="#{movieBean.image}"></h:inputHidden>
									<div class="feild-action">
										<p:commandButton value="#{msg['btn_yes']}"
											action="#{movieBean.delete()}"
											oncomplete="confirm_del_movie.hide()"
											update=":mainform,:growl"></p:commandButton>
										<p:commandButton value="#{msg['btn_no']}"
											onclick="confirm_del_movie.hide()"></p:commandButton>
									</div>
								</h:panelGroup>


							</p:confirmDialog>
						</h:form>
						<h:form>
							<p:commandButton onclick="dlg.show()"
								title="#{msg['btn_insert']}" icon="ui-icon ui-icon-plusthick"
								update=":dlgform:dlgisert">
								<f:param value="movieico.png" name="imageI"></f:param>
								<f:param value="insert" name="action"></f:param>
							</p:commandButton>
							<h:outputText value="#{msg['menu_admin_movie']}"
								style="margin-left:5px;font-size: 20px;font-weight: bold;"></h:outputText>
						</h:form>
					</div>
					<div class="dth_admin_main">
						<h:panelGroup id="mainform">
							<p:dataTable styleClass="myTable" var="item" paginator="true"
								rows="4" paginatorPosition="bottom"
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								value="#{movieBean.listMovie}" rowIndexVar="row">
								<p:column headerText="Stt">
									<h:outputText value="#{row+1}" />
								</p:column>
								<p:column headerText="#{msg['book_movie_name']}">
									<h:outputText style="float:left;" value="#{item.movieName}">
									</h:outputText>
								</p:column>
								<p:column headerText="#{msg['book_movie_price']}">
									<h:outputText style="float:left;" value="#{item.moviePrice}$">
									</h:outputText>
								</p:column>
								<p:column headerText="#{msg['description']}">
									<h:outputText style="float:left;" escape="false"
										value="#{item.description}">
									</h:outputText>
								</p:column>
								<p:column headerText="#{msg['date_insert']}">
									<h:outputText style="float:left;" value="#{item.dateInsert}">
									</h:outputText>
								</p:column>
								<p:column headerText="#{msg['image']}" style="width:20px">
									<img width="250px" height="130px" src="images/#{item.image}"
										alt="#{item.movieName}" />
								</p:column>
								<p:column headerText="#{msg['menu_action']}">
									<h:form style="text-align: center;">
										<p:commandLink onclick="confirm_del_movie.show()"
											update=":form_confirm_delete_movie:data">
											<f:param value="delete" name="action"></f:param>
											<f:param value="#{item.movieId}" name="movie_id"></f:param>
											<f:param value="#{item.image}" name="movie_image"></f:param>
											<img src="images/icon_delete.png"
												title="#{msg['btn_delete']}" />
										</p:commandLink>
										<p:commandLink onclick="dlg2.show()"
											update=":dlgform2:dlgupdate">
											<f:param value="update" name="action"></f:param>
											<f:param value="#{item.movieId}" name="movie_id"></f:param>
											<img src="images/icon_edit.png" title="#{msg['btn_edit']}" />
										</p:commandLink>

									</h:form>

								</p:column>
							</p:dataTable>
						</h:panelGroup>
					</div>
				</div>
			</div>
		</div>
	</div>
	<ui:insert name="header">
		<ui:include src="/footer/footer_dth.xhtml" />
	</ui:insert>

</h:body>
</html>